﻿CREATE PROCEDURE [dbo].[proc_Employee_WageSeries_Update]
	(
		@WSId uniqueidentifier, 
		@Num nvarchar(50),
		@Title nvarchar(50),
		@CompanyList nvarchar(500)
	)
AS
	--更新主表
	Update Employee_WageSeries Set Num=@Num,Title=@Title Where WSId = @WSId
	--删除从表
	Delete From Employee_WageSeries_Company Where WSId=@WSId
	--插入主表
	Declare @i int
		Set @i=0
		while(@i<len(@CompanyList))
			Begin
				Insert Into Employee_WageSeries_Company(CompanyId,WSId) Values(substring(@CompanyList,@i,charindex(',',@CompanyList,@i)-@i),@WSId)
				Set @i=charindex(',',@CompanyList,@i)+1
			End
	RETURN
